# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tekdefense-automater
pkgver=88.42548cf
pkgrel=5
groups=('blackarch' 'blackarch-forensic')
pkgdesc='IP URL and MD5 OSINT Analysis'
arch=('any')
url='https://github.com/1aN0rmus/TekDefense-Automater'
license=('MIT')
depends=('python2')
makedepends=('git')
source=("$pkgname::git+https://github.com/1aN0rmus/TekDefense-Automater.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|/usr/bin/python|/usr/bin/python2|g' Automater.py
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  for f in *.py ; do
    install -m 644 $f "$pkgdir/usr/share/$pkgname/$f"
  done

  install -Dm 644 -t "$pkgdir/usr/share/$pkgname/" *.xml
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm 644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"

  cp -a docs/* "$pkgdir/usr/share/doc/$pkgname/"

  cat > "$pkgdir/usr/bin/automater" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 Automater.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/automater"
}

